/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package drt;

import evaluation.Graph;
import java.util.LinkedHashSet;
import java.util.Map;
import logic.Type;

/**
 *
 * @author phong
 */
public class DrtConstant implements DrtEntity{
    
    String name;
    
    public DrtConstant(String name) {
        this.name = name;
    }
    
    @Override
    public Type getType() {
        return Type.ENTITY_TYPE;
    }
    
    @Override
    public void setType(Type t) {}
    
    @Override
    public void setName(String name) {}
    
    @Override
    public String getName() {
        return this.name;
    }
    
    @Override
    public void getAllVariables(LinkedHashSet<DrtVariable> vars) {
    }

    @Override
    public void getRefs(LinkedHashSet<DRSReferent> refs) {
    }
    
    @Override
    public DrtEntity simplify() {
        return this;
    }
    
    @Override
    public DrtEntity replace(DrtVariable var, DrtExpression exp) {
        return this;
    }
    
    @Override
    public boolean equals(Object other) {
        if (other instanceof DrtConstant)
            return this.name.equals(((DrtConstant)other).name);
        else 
            return false;
    }
    
    @Override
    public int hashCode() {
        return this.name.hashCode();
    }
    
    @Override
    public String toString() {
        return this.name;
    }
    
    @Override
    public Graph toGraph() {
        return new Graph();
    }
 
    @Override
    public DrtConstant getTemplate(Map<String,String> map) {
        String template = map.get(name);
        
        if (template == null) {
            template = TemplateNaming.getUniqueName();
            map.put(name, template);
        }
        return new DrtConstant(template);
    }
}

